<style src="./index.scss" lang="scss" scoped rel="stylesheet/scss"></style>
<template src="./index.html"></template>
<script>
import apiConfig from "./../apiConfig";
export default {
  props: {
    // 使用者window实例 必定义
    appWindow: {
      type: Object,
      default: null,
    },
    // 接口列表
    apiConfig: {
      type: Object,
      default: apiConfig,
    },
    value: {
      type: Array,
      default: [],
    },
    // 是否禁用
    disabled: {
      type: Boolean,
      default: false,
    },
  },

  components: {},
  data() {
    return {
      dataList: [],
      dataValue: [],
    };
  },

  methods: {
    async getData() {
      let _data = await this.$vFN.Http.post(
        {
          url: this.apiConfig.groupList.url,
          domain: this.apiConfig.groupList.domain,
          data: {
            productIdLst: this.value,
          },
        },
        this.appWindow
      );
      if (_data._ok) {
        this.dataList = this.$vFN.Tools.reSelectTreeDataSource({
          data: _data.data,
        });
        console.error(this.dataList);
      }
    },
    handleChange(e) {
      console.error(e);
      this.$emit("input", [...e]);
    },
  },
  watch: {
    value: {
      handler(newVal, oldVal) {
        this.dataValue = newVal;
      },
      immediate: true,
      deep: true,
    },
  },

  mounted() {
    this.getData();
  },
  beforeCreate() {},
};
</script>